
const { ccclass, property } = cc._decorator;

@ccclass
export default class Hero extends cc.Component {



	@property(cc.Label)
	hpLabel: cc.Label = null;

	@property(cc.Label)
	atkLabel: cc.Label = null;

	@property(cc.Label)
	defLabel: cc.Label = null;

	@property(cc.Label)
	expLabel: cc.Label = null;

	@property(cc.Label)
	lvLabel: cc.Label = null;

	@property(cc.Label)
	moneyLabel: cc.Label = null;

	@property(cc.Label)
	greenkeyLabel: cc.Label = null;

	@property(cc.Label)
	redkeyLabel: cc.Label = null;

	@property(cc.Label)
	bluekeyLabel: cc.Label = null;

	@property(cc.TiledMap)
	tiled: cc.TiledMap = null;

	hp: number = 0;         	//生命
	atk: number = 0;         	//攻击力
	def: number = 0;         	//防御力
	exp: number = 0;         	//经验
	lv: number = 0;         	//等级
	money: number = 0;     		//金币
	greenkey: number = 0;   	//黄钥匙
	bluekey: number = 0;    	//蓝钥匙
	redkey: number = 0;     	//红钥匙

	set Hp(hp: number) {
		this.hp = hp;
		this.hpLabel.string = hp.toString();
	}

	set Atk(atk: number) {
		this.atk = atk;
		this.atkLabel.string = atk.toString();
	}

	set Def(def: number) {
		this.def = def;
		this.defLabel.string = def.toString();
	}

	set Exp(exp: number) {
		this.exp = exp;
		this.expLabel.string = exp.toString();
	}

	set Lv(lv: number) {
		this.lv = lv;
		this.lvLabel.string = lv.toString();
	}

	set Money(money: number) {
		this.money = money;
		this.moneyLabel.string = money.toString();
	}

	set Greenkey(greenkey: number) {
		this.greenkey = greenkey;
		this.greenkeyLabel.string = greenkey.toString();
	}

	set Bluekey(bluekey: number) {
		this.greenkey = bluekey;
		this.bluekeyLabel.string = bluekey.toString();
	}

	set RedKey(redkey: number) {
		this.redkey = redkey;
		this.redkeyLabel.string = redkey.toString();
	}


	isCanMove(v3: cc.Vec3): boolean {
		// let wall: Entity = this.tiled.node.getComponent('wall');
		return true;
	}

	moveEvent(tild: cc.Vec3) {
		// let item: Entity = this.tiled.node.getComponent('item');
		// item.doEvent(tild, this.node);

		// let enemy: Entity = this.tiled.node.getComponent('Enemy');
		// enemy.doEvent(tild, this.node);

		// let door: Entity = this.tiled.node.getComponent('door');
		// door.doEvent(tild, this.node);
	}

	doEvent(v3: cc.Vec3, node: cc.Node): void {
		//throw new Error("Method not implemented.");
	}

	onLoad() {
		this.Hp=100;
		this.Def=5;
		this.Atk=10;
		this.Lv=1;
	}

	// start() {}

	// update (dt) {}



}
